﻿Public Class TMyTrigger
    Inherits TCustomMyObject

    Friend _TriggerCatalog As String
    Friend _TriggerSchema As String
    Friend _TriggerName As String
    Friend _EventManipulation As String
    Friend _EventObjectCatalog As String
    Friend _EventObjectSchema As String
    Friend _EventObjectTable As String
    Friend _ActionOrder As Integer
    Friend _ActionCondition As String
    Friend _ActionStatement As String
    Friend _ActionOrientation As String
    Friend _ActionTiming As String
    Friend _ActionReferenceOldTable As String
    Friend _ActionReferenceNewTable As String
    Friend _ActionReferenceOldRow As String
    Friend _ActionReferenceNewRow As String
    Friend _Created As DateTime
    Friend _SqlMode As String
    Friend _Definer As String
    Friend _CharacterSetClient As String
    Friend _CollationConnection As String
    Friend _DatabaseCollation As String

    Friend Sub New(ByVal AOwner As TCustomMyObjects, ByVal AObjectName As String)
        MyBase.New(AOwner, AObjectName)
    End Sub
    Private Sub InitSource()
        MyQuery.Clear()
        MyQuery.SQL.Append("show create trigger `").Append(Me.TriggerSchema).Append("`.`").Append(Me.TriggerName).Append("`")
        MyQuery.Execute()
        _Source = MyQuery.FieldAsString("SQL Original Statement")
        MyQuery.Close()
    End Sub
    Public Overrides ReadOnly Property Source() As String
        Get
            InitSource()
            Return _Source
        End Get
    End Property

    Public ReadOnly Property TriggerCatalog() As String
        Get
            Return _TriggerCatalog
        End Get
    End Property

    Public ReadOnly Property TriggerSchema() As String
        Get
            Return _TriggerSchema
        End Get
    End Property

    Public ReadOnly Property TriggerName() As String
        Get
            Return _TriggerName
        End Get
    End Property

    Public ReadOnly Property EventManipulation() As String
        Get
            Return _EventManipulation
        End Get
    End Property

    Public ReadOnly Property EventObjectCatalog() As String
        Get
            Return _EventObjectCatalog
        End Get
    End Property

    Public ReadOnly Property EventObjectSchema() As String
        Get
            Return _EventObjectSchema
        End Get
    End Property

    Public ReadOnly Property EventObjectTable() As String
        Get
            Return _EventObjectTable
        End Get
    End Property

    Public ReadOnly Property ActionOrder() As Integer
        Get
            Return _ActionOrder
        End Get
    End Property

    Public ReadOnly Property ActionCondition() As String
        Get
            Return _ActionCondition
        End Get
    End Property

    Public ReadOnly Property ActionStatement() As String
        Get
            Return _ActionStatement
        End Get
    End Property

    Public ReadOnly Property ActionOrientation() As String
        Get
            Return _ActionOrientation
        End Get
    End Property

    Public ReadOnly Property ActionTiming() As String
        Get
            Return _ActionTiming
        End Get
    End Property

    Public ReadOnly Property ActionReferenceOldTable() As String
        Get
            Return _ActionReferenceOldTable
        End Get
    End Property

    Public ReadOnly Property ActionReferenceNewTable() As String
        Get
            Return _ActionReferenceNewTable
        End Get
    End Property

    Public ReadOnly Property ActionReferenceOldRow() As String
        Get
            Return _ActionReferenceOldRow
        End Get
    End Property

    Public ReadOnly Property ActionReferenceNewRow() As String
        Get
            Return _ActionReferenceNewRow
        End Get
    End Property

    Public ReadOnly Property Created() As DateTime
        Get
            Return _Created
        End Get
    End Property

    Public ReadOnly Property SqlMode() As String
        Get
            Return _SqlMode
        End Get
    End Property

    Public ReadOnly Property Definer() As String
        Get
            Return _Definer
        End Get
    End Property

    Public ReadOnly Property CharacterSetClient() As String
        Get
            Return _CharacterSetClient
        End Get
    End Property

    Public ReadOnly Property CollationConnection() As String
        Get
            Return _CollationConnection
        End Get
    End Property

    Public ReadOnly Property DatabaseCollation() As String
        Get
            Return _DatabaseCollation
        End Get
    End Property

End Class
